package javacore.abstraction;

public class StaticFinalVariable {
	// "static final" guarantees that a variable will be initialized by the end of class initialization code.
	static final double PI1 = Math.atan(1) * 4;
	static final double PI2 = getPI();
	static final double PI3;
	static final double wrongPI = 22.0 / 7.0;
	
	static {
		// We can initialize static final vars in Static block
		PI3 = Math.atan(1) * 4;
	}
	static void Test(){
		// We can not initialize final variables in static method
		//PI3 = 22 / 7; // Error
	}
	
	public static void main (String args[]){
		System.out.printf("PI1 = %f, PI2 = %f, PI3 = %f", PI1, PI2, PI3);
		System.out.println("\nWrong value of PI = " + wrongPI);
	}
	
	static double getPI(){
		return Math.atan(1) * 4;
	}

}
